package com.cby.android.base.contentprovider

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.cby.android.base.R
import android.database.ContentObserver
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.View


/**
 * @description: ContentProviderActivity
 *
 * @author ChenBaoyang
 * @date 2021/10/13 16:23
 */
class ContentProviderActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_content_provider)
        contentResolver.registerContentObserver(
            Constant.CONTENT_URI,
            true, UserObserver(Handler(Looper.myLooper()!!))
        )
    }

    class UserObserver(handler: Handler?) : ContentObserver(handler) {
        override fun onChange(selfChange: Boolean) {
            Log.i("chenby","selfChange = $selfChange")
        }
    }

    fun onTest(view: View) {
        InitializeManager.instance.showToast("测试InitializeManager是否初始化了")
    }

    fun onTest2(view: View) {
        startActivity(Intent(this@ContentProviderActivity, ContentProcessActivity::class.java))
    }
}